<?php
class IdWork{

	const INDEX = "0123456789abcdefghijklmnopqrstuvwxyz";

	const INDEXLEN = 36;
	
	public static function generateId($num) { 
		$out = '';	
		$t = ($num == 0) ? 0 : floor(log10($num) / log10(self::INDEXLEN)); 
		for ($t; $t >= 0; $t--) { 
			$order = floor($num / pow( self::INDEXLEN, $t )); 
			$out = $out . substr( self::INDEX, $order, 1); 
			$num = $num - ($order * pow( self::INDEXLEN, $t )); 
		} 
		return $out; 
	} 
}
